package com.taiyuan.tongcheng.util;
import org.kymjs.kjframe.utils.DensityUtils;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.util.DisplayMetrics;
import android.view.Window;
import android.view.WindowManager;

import com.tytc56.user.R;


public class DialogUtil {
	public static Dialog getLoginDialog(Activity context) {

		final Dialog dialog = new Dialog(context, R.style.dialog);
		dialog.setContentView(R.layout.layout_progress_dialog);
		Window window = dialog.getWindow();
		WindowManager.LayoutParams lp = window.getAttributes();
		int screenW = getScreenWidth(context);
		lp.width = (int) (0.6 * screenW);
		dialog.setCancelable(true);
		dialog.setCanceledOnTouchOutside(false);
		return dialog;
	}
	public static Dialog getTcLoadding(Activity context) {
		
		final Dialog dialog = new Dialog(context, R.style.dialog);
		dialog.setContentView(R.layout.layout_progress_tcdialog);
		Window window = dialog.getWindow();
		WindowManager.LayoutParams lp = window.getAttributes();
		int screenW = getScreenWidth(context);
		lp.width = (int) (0.6 * screenW);
		dialog.setCancelable(true);
		dialog.setCanceledOnTouchOutside(false);
		return dialog;
	}
	public static Dialog getTcLoadding(Context context) {
		
		final Dialog dialog = new Dialog(context, R.style.dialog);
		dialog.setContentView(R.layout.layout_progress_tcdialog);
		Window window = dialog.getWindow();
		WindowManager.LayoutParams lp = window.getAttributes();
		lp.width = (int) (0.6 * DensityUtils.getScreenW(context));
		dialog.setCancelable(true);
		dialog.setCanceledOnTouchOutside(false);
		return dialog;
	}
	
	

	public static int getScreenWidth(Activity context) {
		DisplayMetrics dm = new DisplayMetrics();
		context.getWindowManager().getDefaultDisplay().getMetrics(dm);
		return dm.widthPixels;
	}

	public static int getScreenHeight(Activity context) {
		DisplayMetrics dm = new DisplayMetrics();
		context.getWindowManager().getDefaultDisplay().getMetrics(dm);
		return dm.heightPixels;
	}
}
